package text;


import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.lankystar.logistucs.spring.entity.Company;
import com.lankystar.logistucs.spring.entity.User;
import com.lankystar.logistucs.spring.entity.UserType;
import com.lankystar.logistucs.spring.service.CompanyService;
import com.lankystar.logistucs.spring.service.UserService;
import com.lankystar.logistucs.spring.service.UserTypeService;

public class UserText {
/**
 * 添加三大管理员，一个超级管理员
 */
	ApplicationContext act = null;
	UserService userService=null;
	UserTypeService userTypeService = null;
	CompanyService companyService = null;
	UserType record = null;
	@Before
	public void inti(){
		act = new ClassPathXmlApplicationContext("spring-beans.xml");
		userService = (UserService) act.getBean("userServiceImpl");
		userTypeService = (UserTypeService) act.getBean("userTypeServiceImpl");
		companyService = (CompanyService) act.getBean("companyServiceImpl");
		record = userTypeService.queryUserTypeById(1);
	}
	@Test
	public void a() {
		UserType userType2 = userTypeService.queryUserTypeById(2);
		/**
		 * 添加公司
		 */
		Company company2 = new Company();
		company2.setCompanyName("牛叉叉运输队");
		company2.setIntroduce("超牛的运输公司");
		companyService.addCompany(company2);
		
		User user2 = new User();
		user2.setUserId(1);
		user2.setUserName("运输队");
		user2.setUserPassword("123456");
		user2.setUserPhone("15229360942");
		user2.setUserType(userType2);
		user2.setCompany(company2);
		user2.setUsual(0);
		user2.setRemove(0);
		userService.addUser(user2);
		
	}
	@Test
	public void b() {
		UserType userType3= userTypeService.queryUserTypeById(3);
		/**
		 * 添加公司
		 */
		Company company3= new Company();
		company3.setCompanyName("上海报关行");
		company3.setIntroduce("贼牛的报关公司");
		companyService.addCompany(company3);
		
		User user3 = new User();
		user3.setUserId(2);
		user3.setUserName("报关公司");
		user3.setUserPassword("123456");
		user3.setUserPhone("15229360943");
		user3.setUserType(userType3);
		user3.setCompany(company3);
		user3.setUsual(0);
		user3.setRemove(0);
		userService.addUser(user3);
		
		
	}
	@Test
	public void c() {
		UserType userType1 = userTypeService.queryUserTypeById(4);
		/**
		 * 添加公司
		 */
		Company company1 = new Company();
		company1.setCompanyName("苏州报关行");
		company1.setIntroduce("超牛的报关公司");
		companyService.addCompany(company1);
		
		User user1 = new User();
		user1.setUserId(3);
		user1.setUserName("申请报关公司");
		user1.setUserPassword("123456");
		user1.setUserPhone("15229360941");
		user1.setUserType(userType1);
		user1.setCompany(company1);
		user1.setUsual(0);
		user1.setRemove(0);
		userService.addUser(user1);
		
		
	}
	@Test
	public void d() {
		/**
		 * 超级管理员
		 */
		UserType userType = userTypeService.queryUserTypeById(1);
		User user = new User();
		user.setUserId(4);
		user.setUserName("admin");
		user.setUserPassword("123456");
		user.setUserPhone("15229360944");
		user.setUserType(userType);
		user.setUsual(0);
		user.setRemove(0);
		userService.addUser(user);
	}

	public static void main(String[] args) {
		String beginDate="1468388445491";  
	  
	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
	  
	String sd = sdf.format(new Date(Long.parseLong(beginDate)));  
	  
	System.out.println(sd);  
	}
}
